/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.weso.acota.appserv;


import java.util.LinkedList;
import java.util.List;
import org.weso.acota.dao.CPVSuggestDAOImpl;
import org.weso.acota.dao.DeliciousSuggestDAOImpl;
import org.weso.acota.dao.GoogleSuggestDAOImpl;
import org.weso.acota.dao.SuggestDAO;
import org.weso.acota.dao.TwitterSuggestDAOImpl;
import org.weso.acota.dao.YQLSuggestDAOImpl;
import org.weso.acota.strategy.CotaCollectStrategy;
import org.weso.acota.strategy.CotaSortStrategy;
import org.weso.acota.strategy.DummyCotaCollectStrategy;
import org.weso.acota.strategy.DummyCotaSortStrategy;
import org.weso.acota.to.RequestSuggestionTO;
import org.weso.acota.to.SuggestionTO;

/**
 *
 * @author chema
 */
public class SuggestAppServ {

    private List<SuggestDAO> suggestDAO;
    private CotaCollectStrategy collectStrategy;
    private CotaSortStrategy sortStrategy;

    public SuggestAppServ(){
        this.suggestDAO = createDAOs();
        this.collectStrategy = new DummyCotaCollectStrategy();
        this.sortStrategy = new DummyCotaSortStrategy();
    }

    private List<SuggestDAO> createDAOs(){
        List<SuggestDAO> daos = new LinkedList<SuggestDAO>();
        daos.add(new GoogleSuggestDAOImpl());
        daos.add(new YQLSuggestDAOImpl());
        daos.add(new TwitterSuggestDAOImpl());
        daos.add(new CPVSuggestDAOImpl());
       // daos.add(new DeliciousSuggestDAOImpl());
        return daos;
    }
    public SuggestionTO suggest(RequestSuggestionTO request) {
        SuggestionTO result = this.collectStrategy.suggest(request, suggestDAO);
        return this.sortStrategy.suggest(result);
    }
}
